/*
 * AlbumFileAssistant
 */
package filesystem;

import filesystem.exceptions.InvalidModelItemException;
import java.util.*;
import model.*;

/**
 *
 * @author ArieS
 */
public class AlbumFileAssistant extends FileAssistantAbstract {

    private static AlbumFileAssistant instance;

    private AlbumFileAssistant() {
        super("\\MusicLibrary\\albums", ".alb", "album");
    }

    public static AlbumFileAssistant getInstance() {
        if (instance == null) {
            instance = new AlbumFileAssistant();
        }
        return instance;
    }

    @Override
    protected ModelItem mapToItem(Map map) {
        ModelItem mi = null;
        try {
            mi = new Album(Integer.parseInt(map.get("id").toString()),
                    map.get("name").toString());
            mi.setVersion(Integer.parseInt(map.get("version").toString()));
        } catch (Exception ex) {
            throw new InvalidModelItemException();
        }
        return mi;
    }
}
